UserSpace:BM-Development Tools
__TOC__ Subversion Subversion is a popular version control system used to manage and maintain current and historical versions of files. Quick cheat sheet exists here Useful Commands 'svn help' : Shows all basic commands . 'svn help command': Shows description and usages of command; where command is a specific instruction. 'svnadmin help' : Shows all admin commands. 'svnadmin create filename' : Creates svn repo with filename. 'svn info subversion URL' : Gives information about repository 'svn status working copy' : Give information about a working copy. NOTE, This doesn't work with repositories. NOTE , adding the verbose option prints out full revision information on every item in the working copy. 'svn co subversion URL working copy path' : Checks out a working copy to the given path. NOTE, if the path is omitted as its optional, the base name of the URL will be used as the destination. 'svn rename src dest' : Renames the src to the dest; this is equivalent to doing a copy to the dest and a delete of the src. Quick Sequence to create a repo *svn admin create project path *setup project structure eg project branches, tags, trunk etc. using normal directory creation commands. *import needed project folder into subversion, for eg to import dbProj into trunk in subversion **create dbProj folder and then **svn import dbProj file:///url or path to subversion repo/dbProj -m "message for commit" *to check out dbProj **svn co file:///url or path to subversion repo/dbProj working copy path/url SVN Gotchas * Checking out a revision with a date without specifying a time of day checks out the previous days revision. For eg if the intention is to checkout code for the 27th, without specifying a time svn will checkout the latest revision on the 26th. This is because without specifying the time subversion assumes a time of 00:00:00 if a time stamp argument is not specified ** To get around this, specify the 27th with the time or specify the next day instead; 28th. * In the scenario where the "svn mkdir" command is used to create a directory, attempting to move or copy the directory will result in the message "Unable to lock 'working copy'" where working copy is your local working directory. This situation is possibly caused by the use of an absolute path. Using a relative path may resolve the issue. * Attempting to commit without a save message if $SVN_EDITOR environment variable is not set or without a file pipe will result in the commit failing *Attempting to delete a folder / file from a working copy which has local uncommitted changes results in failure. To override this behaviour use the '--force' parameter to force the deletion. Bernard Mensah 14:05, December 3, 2009 (UTC) FxCop FXCop analyses managed code assemblies that targets the Dot Net Common Language Runtime and reports information about the assembly. It has a command line client which is useful for automated analysis of code called FXCopCommand In order to perform an FXCop analysis, one can typically access the projects fxcop file in the build folder of the project. Analysis can be done using the F5 accelerator key or by using the project menu to access the analyze menu item. Issues can either be new, active, excluded in project, excluded in source or absent. New: The message was reported in the most recent analysis and was not previously present in the project in any other state. Active: The message was reported in the most recent analysis. It might or might not be in the New state. Excluded In Project: The message was manually removed from the active list. Absent: The message was once in the active list, is not excluded, and was not reported in the most recent analysis. Bernard Mensah 13:34, December 7, 2009 (UTC) Nant Nant is a free .Net build tool that integrates into Visual Studio. Installing Nant is pretty straightforward, One only needs to download and unzip the zip from this link into a suitable location and add the path to the Nant folder to the environment path. There are several GUI clients for Nant. I am currently trialling out NAnt-Gui Setting the path for a Nant installation Assuming the path where the nant folder has been extracted to is C:\Nant *Open a command line prompt. *Use the Set Path command to add the path to the bin folder in the Nant directory ** SET PATH=%PATH%;C:\Nant\bin. NOTE: Ensure that the initial path directive '"%PATH%;"' is included otherwise it may delete all the other options that are currently set in your path. *To run a build file called helloworld.build **nant /f:helloworld.build **The /f directive is the short form of the -buildfile option. Heres a "Hello World" Nant file Hello Bernard Mensah 14:02, December 7, 2009 (UTC) In Nant a project has 4 attributes that are not required, namely its *Name: The name of the project *Default : The default target to execute if no command line arguments are passed in. *BaseDir: The base directory from which all path calculations are done. Note : If this is not set, the parent directory of the build file will be used instead. *Description: This is used when the '-projecthelp' command line option is used. Targets in Nant refer to the set of 'tasks' to be executed, whereas a task is a piece of code that can be executed. Tasks have a common structure : Bernard Mensah 09:11, December 8, 2009 (UTC) Changing the Target Framework NAnt supports three ways for changing the target framework: *From the command line, using the -targetframework argument: For example NAnt.exe -t:net-1.0 will target the .Net 1.0 framework. *By changing the default target framework in the NAnt configuration file: ... By changing the value of the system property nant.settings.currentframework: A More Complicated Example A good tutorial to writing custom tasks in Nant can be found here. A good explanation of the pros and cons of using Depends vs Calls can be found here as well. A good initial look at targeting multiple environments through build scripts can be seen here. Batch Files A good start on writing dos files exists here An Example Batch File @ECHO OFF :: --------------------------------------------------------------------- :: This batch file creates a subversion repository :: structure from supplied arguments. :: Author: Bernard Mensah :: --------------------------------------------------------------------- :: --------------------------------------------------------------------- :: Check to see if directories argument has been supplied. :: --------------------------------------------------------------------- IF %1 EQU [] ( @ECHO Please specify a repository directory. GOTO :EOF ) :: --------------------------------------------------------------------- :: Check to see if temporary directory exists :: --------------------------------------------------------------------- IF %2 EQU [] ( @ECHO Please specify a temporary directory. GOTO :EOF ) :: --------------------------------------------------------------------- :: Create a repo directory. :: --------------------------------------------------------------------- SET ans=Y IF EXIST %1 ( SET /P ans=Directory %1 already exists. Delete ^(y/n^)? ) IF /I NOT %ans% Y ( @ECHO Please specify an empty directory or a directory @ECHO that can be deleted. GOTO :EOF ) IF EXIST %1 ( RMDIR /S /Q %1 ) svnadmin create %1 :: --------------------------------------------------------------------- :: Create a temporary directory structure. :: --------------------------------------------------------------------- SET ans=Y IF EXIST %2 ( SET /P ans=Directory %2 already exists. Delete ^(y/n^)? ) IF /I NOT %ans% Y ( @ECHO Please specify an empty directory or a directory @ECHO that can be deleted. GOTO :EOF ) IF EXIST %2 ( RMDIR /S /Q %2 ) MKDIR %2\ShoppingCart\Trunk PUSHD %2\ShoppingCart\Trunk MKDIR Docs Build Src POPD MKDIR %2\ShoppingCart\Branches MKDIR %2\ShoppingCart\Tags :: --------------------------------------------------------------------- :: Import directory into repository :: --------------------------------------------------------------------- svn import %2\ShoppingCart file:///%1 -m "Importing project structure" RMDIR /S /Q %2 Bernard Mensah 15:28, December 16, 2009 (UTC) Category:BM-Learning